//package com.zhouyu.jpademo.service;
//
//import com.zhouyu.jpademo.repository.oneToMany.DepartMentDao;
//import com.zhouyu.jpademo.repository.oneToMany.StudentDao;
//import com.zhouyu.jpademo.entity.oneToMany.onway.DepartMent;
//import com.zhouyu.jpademo.entity.oneToMany.onway.Student;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.List;
//import java.util.Optional;
//
///**
// * @Description:
// */
//@Service
//public class StudentService {
//  @Autowired
//  StudentDao studentDao;
//
//  @Autowired
//  DepartMentDao departMentDao;
//
//  @Transactional(rollbackFor = {RuntimeException.class})
//  public void create(List<Student> students, DepartMent departMent) {
//    departMentDao.save(departMent);
//    students.forEach(student -> {
//      studentDao.save(student);
//    });
//  }
//
//  public List<Student> getSudent(String name) {
//    return studentDao.findByName(name);
//  }
//
//  public List<Student> getSudentWithDepartId(Long departMentId) {
//    return studentDao.findByDepartMent_Id(departMentId);
//  }
//
//  public List<Student> getSudentWithDepart(DepartMent departMent) {
//    return studentDao.findByDepartMent(departMent);
//  }
//
//  public List<DepartMent> getDepartment(String name){
//    return departMentDao.findByName(name);
//  }
//
//  public DepartMent getDepartment(Long id){
//    Optional<DepartMent> option = departMentDao.findById(id);
//    return option.get();
//  }
//
//  public void deleteStudent(Long id){
//    studentDao.deleteById(id);
//  }
//
//  public void deleteDepartMent(Long id){
//    departMentDao.deleteById(id);
//  }
//
//  public void updateDepart(DepartMent departMent){
//    departMentDao.save(departMent);
//  }
//
//}
